﻿
(function () {
    appModule.controller('common.views.disputeInformationHandles.timeStatistics', [
         '$scope', '$uibModalInstance', 'abp.services.app.disputeInformation', 'abp.services.app.area', '$filter',
        function ($scope, $uibModalInstance, disputeInformationService, areaService, $filter) {
            var vm = this;
            //默认是关闭高级按钮。我们这里用不到。参考
            //vm.advancedFiltersAreShown = false;

            vm.filterText = '';

            vm.dateRangeOptions = app.createDateRangePickerOptions_extend();
            vm.dateRangeModel = {
                startDate: '',
                endDate: ''
            };

            //请求参数，默认用于分页
            vm.requestParams = {
                permission: '',
                role: '',
                skipCount: 0,
                //这里是个常量文件，如果你没有找到这个常量文件，那么就手动改成10吧
                maxResultCount: app.consts.grid.defaultPageSize,
                sorting: null,
                party: "",
                townID: 0,
                areaID: 0,
                villageID: 0
            };

            //取消关闭页面
            vm.cancel = function () {
                $uibModalInstance.dismiss();
            };

            //声明查询方法
            vm.getTimeStatistics = function () {
                disputeInformationService.getTimeStatistics($.extend(vm.requestParams, vm.dateRangeModel))
                    .then(function (result) {
                        var data = result.data.items;
                        vm.timeStatisticsList = data;

                        vm.sum_shouLi = 0;
                        vm.sum_fenLiu = 0;
                        vm.sum_tiaoJie = 0;
                        vm.sum_duBan = 0;
                        vm.sum_huiFang = 0;
                        vm.sum_jieAn = 0;
                        vm.sum_qiTaQuDao = 0;
                        for (var i = 0; i < data.length; i++) {
                            vm.sum_shouLi += data[i].shouLi;
                            vm.sum_fenLiu += data[i].fenLiu;
                            vm.sum_tiaoJie += data[i].tiaoJie;
                            vm.sum_duBan += data[i].duBan;
                            vm.sum_huiFang += data[i].huiFang;
                            vm.sum_jieAn += data[i].jieAn;
                            vm.sum_qiTaQuDao += data[i].qiTaQuDao;
                        }

                    });
            };

            //初始化页面
            function init() {
                vm.getTimeStatistics();
            }

            //执行初始化方法
            init();
        }
    ]);
})();
